package com.cqupt.controller;


import com.cqupt.paging.Paging;
import com.cqupt.pojo.Acount;
import com.cqupt.service.AcountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
//处理投诉表状态
/** 功能：获取账户表，获取用户表，获取管理员表，增加管理员账号，增加用户，删除账户
 * @author 蒋俊贤
 * @version 1.0
 */

@Controller
public class AcountController {
    @Autowired
    private AcountService acountService;


    @RequestMapping("/acount/list")
    @ResponseBody
    //获取账户表
    public List getAcountList() {
        return acountService.getAcountList();

    }

    @RequestMapping("/acount/listLimit")
    @ResponseBody
    //获取账户表分页
    public Paging getAcountList(Integer number){
        //number = 1;
        return acountService.getAcountList(number);
    }

    @RequestMapping("/acount/getAcount")
    @ResponseBody
    //通过用户名获取账户信息
    public Acount getAcount(String name){
        return acountService.getAcount(name);
    }


    @RequestMapping("/acount/userList")
    @ResponseBody
    //获取用户表
    public List getUserList() {
        return acountService.getUserList();
    }

    @RequestMapping("/acount/userListLimit")
    @ResponseBody
    //获取用户表分页
    public Paging getUserList(Integer number){
        //number = 1;
        return acountService.getUserList(number);
    }

    @RequestMapping("/acount/adminList")
    @ResponseBody
    //获取管理员表
    public List getUAdminList() {
        return acountService.getAdminList();
    }

    @RequestMapping("/acount/adminListLimit")
    @ResponseBody
    //获取管理员表分页
    public Paging getAdminList(Integer number){
        //number = 1;
        return acountService.getAdminList(number);
    }

    @RequestMapping("/acount/addAdmin")
    @ResponseBody
    //增加管理员账号
    public int addAdmin(String username, String pwd, String phone){
        //username = "admin2";
        //pwd = "123";
        //phone = "1675244521";
        return acountService.addAdmin(username, pwd, phone);
    }

    @RequestMapping("/acount/addUser")
    @ResponseBody
    //增加用户账号
    public int addUser(String username, String pwd, String phone){
        //username = "user4";
        //pwd = "123";
        //phone = "1675244522";
        return acountService.addUser(username, pwd, phone);
    }

    @RequestMapping("/acount/updateAcount")
    @ResponseBody
    //修改账户
    public int updateAcount(Acount acount){
        //acount.setId(3);
        //acount.setUsername("admin5");
        //acount.setUserpwd("1234");
        //acount.setPhone("1365425");
        //acount.setRoot(1);

        return acountService.updateAcount(acount);
    }

    //删除账户
    @RequestMapping("/acount/deleteAcount")
    @ResponseBody
    public int deleteAcount(Integer id){
        //id = 7;
        return acountService.deleteAcount(id);
    }

    @RequestMapping("/acount/complaintList")
    @ResponseBody
    //查看投诉表
    public List complaintList(){
        return acountService.complaintList();
    }

    @RequestMapping("/acount/complaintLimit")
    @ResponseBody
    //查看投诉表分页
    public Paging complaintList(Integer number){
        //System.out.println(number);
        //number = 2;
        return acountService.complaintList(number);
    }

    @RequestMapping("/acount/complaintState")
    @ResponseBody
    //处理投诉表状态
    public int complaintState(Integer id){
        //id = 2;
        return  acountService.complaintState(id);
    }
    //时间模糊查询
    @RequestMapping("/acount/complaintFuzzySelect")
    @ResponseBody

    public  Paging complaintFuzzySelect(Integer number ,String fuzzy){
      //number = 1;
      //fuzzy = "48";
      return  acountService.complaintFuzzySelect(number,fuzzy);
    }

}
